package org.zjt.spark

import org.apache.spark.{SparkConf, SparkContext}
import org.zjt.spark.SortWordCount.sc

/**
  * DESC    
  *
  * @author
  * @create 2017-05-10 下午1:42
  **/
object LogHandler extends App{

  val conf = new SparkConf().setAppName("WordCount").setMaster("local")
  val sc = new SparkContext(conf)

 /*
  val result = sc.textFile("./log.txt").flatMap(_.split("\n")).map(_.split(" ")).map( a=> (a(0).replace(":",""),1)).reduceByKey( _+_ )
  println(result.collect().mkString(","))
*/

  val var2 = sc.textFile("./log.txt").flatMap(_.split("\n")).map(_.split(" ")).map( a=> (a(0).replace(":",""),1)).persist()
  println(var2.reduceByKey( _+_ ).collect().mkString(","))

  sc.stop();
}
